package com.zh.mall.service.impl;

import com.github.pagehelper.PageHelper;
import com.zh.mall.mapper.UmsAdminMapper;
import com.zh.mall.mbg.model.UmsAdmin;
import com.zh.mall.mbg.model.UmsAdminExample;
import com.zh.mall.service.UmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZhengHao
 * Created At 2022/7/15.
 **/
@Service
public class UmsServiceImpl implements UmsService {

    @Autowired
    private UmsAdminMapper umsAdminMapper;

    @Override
    public List<UmsAdmin> listAllUmsAdmin() {
        return umsAdminMapper.selectByExample(new UmsAdminExample());
    }

    @Override
    public int craeteUmsAdmin(UmsAdmin umsAdmin) {
        return umsAdminMapper.insertSelective(umsAdmin);
    }

    @Override
    public int updateUmsAdmin(Long id, UmsAdmin umsAdmin) {
        umsAdmin.setId(id);
        return umsAdminMapper.updateByPrimaryKeySelective(umsAdmin);
    }

    @Override
    public int deleteUmsAdmin(Long id) {
        return umsAdminMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<UmsAdmin> listUmsAdmin(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return umsAdminMapper.selectByExample(new UmsAdminExample());
    }

    @Override
    public UmsAdmin getUmsAdmin(Long id) {
        return umsAdminMapper.selectByPrimaryKey(id);
    }
}